/**
 * Created by Administrator on 2017/3/11.
 */

var fs = require('fs');
var gm = require('gm').subClass({imageMagick:true});


var thumbnail  = function(origin_img,out_img,fileType,fileName){
    if (fileType == 'gif'){
        origin_img = origin_img +'[0]';
        out_img = 'public/uploads-min/' + fileName + '.png';
        console.log(out_img);
    }

    var output = gm(origin_img);

    output.resize(100).noProfile().write(out_img,function (err) {
        if(!err){
            console.log('done');
        }else{
            console.log(err.message);
        }
    });
};


module.exports = thumbnail;